#!/bin/bash
#
#$ -cwd
#$ -j y
#$ -S /bin/bash
#

TOOLS=(lg qsw ko cr cb dct)
DIFF=( hd hd koc hd cbc dctc )


DATABASE=$1
SENSOR_ROOT=$2
SEGMENTS='caht'

if [ $# -ne 2 ]; then 
  echo "You have to provide the age as first and the root as second argument (equals foldername)" 
  exit
fi


for SEGMENT in $SEGMENTS
do

	./ipIrisSegmentation.sh $SEGMENT $DATABASE $SENSOR_ROOT

	wait
	
	for i in 0 1 2 3 4 5
	do
		./ipIrisCodeGeneration.sh $SEGMENT ${TOOLS[i]} $DATABASE $SENSOR_ROOT &
		#./irisCalcDistances.sh
	done

	wait

	for i in 0 1 2 3 4 5
        do
                ./ipIrisCalcDistances.sh $SEGMENT ${TOOLS[i]} ${DIFF[i]} $DATABASE $SENSOR_ROOT &
                #./irisCalcDistances.sh
        done

done
wait # wait for all background processes to finish
